
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
  <title>FindCxxTest &mdash; CMake 3.16.5 Documentation</title>

    <link rel="stylesheet" href="../_static/cmake.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    
    <link rel="shortcut icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="FindCygwin" href="FindCygwin.html" />
    <link rel="prev" title="FindCVS" href="FindCVS.html" />
  
 

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="FindCygwin.html" title="FindCygwin"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="FindCVS.html" title="FindCVS"
             accesskey="P">previous</a> |</li>
  <li>
    <img src="../_static/cmake-logo-16.png" alt=""
         style="vertical-align: middle; margin-top: -2px" />
  </li>
  <li>
    <a href="https://cmake.org/">CMake</a> &#187;
  </li>
  <li>
    <a href="../index.html">3.16.5 Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" accesskey="U">cmake-modules(7)</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="findcxxtest">
<span id="module:FindCxxTest"></span><h1>FindCxxTest<a class="headerlink" href="#findcxxtest" title="Permalink to this headline">¶</a></h1>
<p>Find CxxTest unit testing framework.</p>
<p>Find the CxxTest suite and declare a helper macro for creating unit
tests and integrating them with CTest.  For more details on CxxTest
see <a class="reference external" href="http://cxxtest.tigris.org">http://cxxtest.tigris.org</a></p>
<p>INPUT Variables</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CXXTEST_USE_PYTHON [deprecated since 1.3]
    Only used in the case both Python &amp; Perl
    are detected on the system to control
    which CxxTest code generator is used.
    Valid only for CxxTest version 3.
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>NOTE: In older versions of this Find Module,
this variable controlled if the Python test
generator was used instead of the Perl one,
regardless of which scripting language the
user had installed.
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CXXTEST_TESTGEN_ARGS (since CMake 2.8.3)
    Specify a list of options to pass to the CxxTest code
    generator.  If not defined, --error-printer is
    passed.
</pre></div>
</div>
<p>OUTPUT Variables</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CXXTEST_FOUND
    True if the CxxTest framework was found
CXXTEST_INCLUDE_DIRS
    Where to find the CxxTest include directory
CXXTEST_PERL_TESTGEN_EXECUTABLE
    The perl-based test generator
CXXTEST_PYTHON_TESTGEN_EXECUTABLE
    The python-based test generator
CXXTEST_TESTGEN_EXECUTABLE (since CMake 2.8.3)
    The test generator that is actually used (chosen using user preferences
    and interpreters found in the system)
CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3)
    The full path to the Perl or Python executable on the system, on
    platforms where the script cannot be executed using its shebang line.
</pre></div>
</div>
<p>MACROS for optional use by CMake users:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CXXTEST_ADD_TEST(&lt;test_name&gt; &lt;gen_source_file&gt; &lt;input_files_to_testgen...&gt;)
   Creates a CxxTest runner and adds it to the CTest testing suite
   Parameters:
       test_name               The name of the test
       gen_source_file         The generated source filename to be
                               generated by CxxTest
       input_files_to_testgen  The list of header files containing the
                               CxxTest::TestSuite&#39;s to be included in
                               this runner
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>#==============
Example Usage:
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>find_package(CxxTest)
if(CXXTEST_FOUND)
    include_directories(${CXXTEST_INCLUDE_DIR})
    enable_testing()
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>    CXXTEST_ADD_TEST(unittest_foo foo_test.cc
                      ${CMAKE_CURRENT_SOURCE_DIR}/foo_test.h)
    target_link_libraries(unittest_foo foo) # as needed
endif()
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>This will (if CxxTest is found):
1. Invoke the testgen executable to autogenerate foo_test.cc in the
   binary tree from &quot;foo_test.h&quot; in the current source directory.
2. Create an executable and test called unittest_foo.
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>#=============
Example foo_test.h:
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>#include &lt;cxxtest/TestSuite.h&gt;
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>class MyTestSuite : public CxxTest::TestSuite
{
public:
   void testAddition( void )
   {
      TS_ASSERT( 1 + 1 &gt; 1 );
      TS_ASSERT_EQUALS( 1 + 1, 2 );
   }
};
</pre></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="FindCVS.html"
                        title="previous chapter">FindCVS</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="FindCygwin.html"
                        title="next chapter">FindCygwin</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/module/FindCxxTest.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="FindCygwin.html" title="FindCygwin"
             >next</a> |</li>
        <li class="right" >
          <a href="FindCVS.html" title="FindCVS"
             >previous</a> |</li>
  <li>
    <img src="../_static/cmake-logo-16.png" alt=""
         style="vertical-align: middle; margin-top: -2px" />
  </li>
  <li>
    <a href="https://cmake.org/">CMake</a> &#187;
  </li>
  <li>
    <a href="../index.html">3.16.5 Documentation</a> &#187;
  </li>

          <li class="nav-item nav-item-1"><a href="../manual/cmake-modules.7.html" >cmake-modules(7)</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2000-2019 Kitware, Inc. and Contributors.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.3.1.
    </div>
  </body>
</html>